package com.huawei.appgallery.forum.user.usercenter.card;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.forum.base.card.ForumCard;
import com.huawei.appgallery.forum.base.card.bean.Section;
import com.huawei.appgallery.forum.base.card.bean.User;
import com.huawei.appgallery.forum.cards.widget.UserInfoTextView;
import com.huawei.appgallery.forum.user.api.IUserFollow;
import com.huawei.appgallery.forum.user.usercenter.bean.ForumFollowUserCardBean;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import huawei.widget.HwButton;
import java.util.concurrent.atomic.AtomicBoolean;
import o.azb;
import o.bqx;
import o.bqy;
import o.brd;
import o.bsp;
import o.bst;
import o.bsx;
import o.bsy;
import o.cbb.b;
import o.cbb.c;
import o.cbb.e;
import o.cbb.j;
import o.ccc;
import o.cgz;
import o.chy;
import o.evx;
import o.fho;
import o.fjo;
import o.fjq;
import o.fjt;

public class ForumFollowUserCard extends ForumCard implements OnClickListener {
    private String ʻ;
    private User ʼ;
    private TextView ʽ;
    private TextView ˊ;
    private IUserFollow ˊॱ = ((IUserFollow) fho.ˏ().ˋ("User").ॱ(IUserFollow.class));
    private HwButton ˋ;
    private AtomicBoolean ˋॱ = new AtomicBoolean(true);
    private UserInfoTextView ˎ;
    private RelativeLayout ˏ;
    private int ˏॱ = 1;
    private View ͺ;
    private ImageView ॱ;
    private d ॱˊ = new d(this);
    private String ॱॱ;
    private int ᐝ;

    static final class d extends evx {
        private OnClickListener ॱ;

        d(OnClickListener onClickListener) {
            this.ॱ = onClickListener;
        }

        public void ˋ(View view) {
            this.ॱ.onClick(view);
        }
    }

    public ForumFollowUserCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ʽ(view);
        this.ॱ = (ImageView) view.findViewById(b.ʼॱ);
        this.ˎ = (UserInfoTextView) view.findViewById(b.ˎ);
        this.ˊ = (TextView) view.findViewById(b.ʿॱ);
        this.ˋ = (HwButton) view.findViewById(b.ॱ);
        this.ʽ = (TextView) view.findViewById(b.ˈॱ);
        this.ˏ = (RelativeLayout) view.findViewById(b.ˋ);
        view.setOnClickListener(this.ॱˊ);
        this.ॱ.setOnClickListener(this.ॱˊ);
        this.ͺ = view.findViewById(b.ˈ);
        this.ˎ.setNickNameTextSize(this.ʼॱ.getResources().getDimension(e.ˏ));
        return this;
    }

    public void ˏ(CardBean cardBean) {
        if (cardBean instanceof ForumFollowUserCardBean) {
            ForumFollowUserCardBean forumFollowUserCardBean = (ForumFollowUserCardBean) cardBean;
            this.ʼ = forumFollowUserCardBean.ˊ();
            this.ʻ = forumFollowUserCardBean.ॱ();
            this.ᐝ = forumFollowUserCardBean.ʼ();
            this.ॱॱ = forumFollowUserCardBean.ॱˈ();
            Section ᐝ = forumFollowUserCardBean.ᐝ();
            if (forumFollowUserCardBean.ʽ() != 1 || ᐝ == null) {
                this.ʽ.setVisibility(8);
                this.ˏ.setMinimumHeight(this.ʼॱ.getResources().getDimensionPixelSize(e.ˋ));
            } else {
                this.ʽ.setVisibility(0);
                this.ʽ.setText(this.ʼॱ.getResources().getString(j.ˏॱ, new Object[]{ᐝ.ˏ()}));
                this.ˏ.setMinimumHeight(this.ʼॱ.getResources().getDimensionPixelSize(e.ॱ));
            }
            ʻ();
            ˎ();
            if (forumFollowUserCardBean.ॱᐨ()) {
                this.ͺ.setVisibility(8);
            } else {
                this.ͺ.setVisibility(0);
            }
        }
    }

    private void ˎ() {
        this.ˎ.setVisibility(0);
        if (this.ʼ.ॱᐝ()) {
            this.ʼ.ˎ(this.ʼॱ.getString(j.ˋ));
            this.ˎ.setData(this.ʼ);
        } else {
            ᐝ();
            bsx.ˋ(this.ʼॱ, this.ॱ, this.ʼ.ˎ());
        }
        ʽ();
    }

    private void ᐝ() {
        int ˏ = bsp.ˏ(this.ˋ, this.ˋ.getText().toString());
        if (ˏ < this.ʼॱ.getResources().getDimensionPixelOffset(bsy.e.ˌ)) {
            ˏ = this.ʼॱ.getResources().getDimensionPixelOffset(bsy.e.ˌ);
        }
        ˏ = ((azb.ॱ(this.ʼॱ) - (this.ʼॱ.getResources().getDimensionPixelOffset(bsy.e.ʿ) * 4)) - this.ʼॱ.getResources().getDimensionPixelOffset(bsy.e.ˎˎ)) - ˏ;
        if (!this.ʼ.ʼ()) {
            this.ˎ.setContentWidth(ˏ);
        }
        this.ˎ.setData(this.ʼ);
    }

    private void ʽ() {
        String ॱ = bst.ॱ(this.ʼॱ, (long) this.ʼ.ˊॱ());
        this.ˊ.setText(this.ʼॱ.getResources().getString(j.ᐝॱ, new Object[]{ॱ}));
    }

    public void ॱ(chy o_chy) {
    }

    private void ʻ() {
        this.ˋ.setVisibility(0);
        if (this.ʼ.ʼ()) {
            this.ˋ.setVisibility(8);
            return;
        }
        int ʻॱ = this.ʼ.ʻॱ();
        if (ʻॱ == 1) {
            this.ˏॱ = 1;
            this.ˋ.setText(j.ˊॱ);
            this.ˋ.setTextColor(this.ʼॱ.getResources().getColor(c.ˏ));
        } else if (ʻॱ == 2) {
            this.ˏॱ = 1;
            this.ˋ.setText(j.ͺ);
            this.ˋ.setTextColor(this.ʼॱ.getResources().getColor(c.ˏ));
        } else {
            this.ˏॱ = 0;
            if (this.ʼ.ॱᐝ()) {
                this.ˋ.setVisibility(8);
                return;
            } else {
                this.ˋ.setText(j.ʻॱ);
                this.ˋ.setTextColor(this.ʼॱ.getResources().getColor(c.ˊ));
            }
        }
        this.ˋ.setOnClickListener(this);
    }

    public void onClick(View view) {
        bqx.ˊ("ForumFollowUserCard", "onClick");
        if (view.getId() != b.ॱ) {
            ॱॱ();
        } else if (this.ʼ != null && this.ˋॱ.get()) {
            IUserFollow iUserFollow = (IUserFollow) fho.ˏ().ˋ("User").ॱ(IUserFollow.class);
            this.ˋॱ.set(false);
            iUserFollow.ॱ(this.ʼॱ, this.ʼ, this.ˏॱ).ˋ(fjt.ˎ(), new fjq<IUserFollow.b>(this) {
                final /* synthetic */ ForumFollowUserCard ˏ;

                {
                    this.ˏ = r1;
                }

                public void onComplete(fjo<IUserFollow.b> o_fjo_com_huawei_appgallery_forum_user_api_IUserFollow_b) {
                    if (o_fjo_com_huawei_appgallery_forum_user_api_IUserFollow_b.ˊ() && ((IUserFollow.b) o_fjo_com_huawei_appgallery_forum_user_api_IUserFollow_b.ॱ()).ˏ() == 0) {
                        bqx.ˏ("ForumFollowUserCard", "follow action success");
                        this.ˏ.ˋ(this.ˏ.ˏॱ);
                        int ˋ = ((IUserFollow.b) o_fjo_com_huawei_appgallery_forum_user_api_IUserFollow_b.ॱ()).ˋ();
                        if (ˋ != this.ˏ.ʼ.ʻॱ()) {
                            this.ˏ.ʼ.ˎ(ˋ);
                            int ˊॱ = this.ˏ.ʼ.ˊॱ();
                            if (ˋ == 1 || ˋ == 2) {
                                this.ˏ.ʼ.ᐝ(ˊॱ + 1);
                            } else {
                                this.ˏ.ʼ.ᐝ(ˊॱ == 0 ? 0 : ˊॱ - 1);
                            }
                            this.ˏ.ʻ();
                            this.ˏ.ʽ();
                            this.ˏ.ᐝ();
                        } else {
                            return;
                        }
                    }
                    this.ˏ.ˋॱ.set(true);
                }
            });
        }
    }

    private void ॱॱ() {
        if (this.ʼ == null || this.ʼ.ॱᐝ()) {
            bqx.ॱ("ForumFollowUserCard", "launchUserHomePage failed: the user is null or has deleted");
            ccc.ˋ().ॱ(this.ʼॱ, null, 0, this.ʻ);
            return;
        }
        ccc.ˋ().ॱ(this.ʼॱ, this.ʼ.ॱ(), this.ʼ.ˊ(), this.ʻ);
    }

    private void ˋ(int i) {
        String str = "";
        switch (this.ᐝ) {
            case 1:
                str = "HISFOLLOW";
                break;
            case 2:
                str = "HISFANS";
                break;
            case 3:
                str = "MYFOLLOW";
                break;
            case 4:
                str = "MYFANS";
                break;
            case 5:
                str = "RECOMMENDLIST";
                break;
        }
        brd.ॱ.ˋ(bqy.ˋ().ˎ(this.ʼॱ), bqy.ˋ().ˎ(), this.ॱॱ, str, i == 0 ? 1 : 0);
    }
}
